package hos.http;

/**
 * <p>Title: HttpRequestDownload </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2023/4/3 10:49
 */
public class HttpRequestDownload extends HttpRequest<HttpRequestDownload> implements HttpBaseRequestDownload<HttpRequestDownload> {

    public String fileDir;

    public String fileName;

    public boolean isMD5Verify = false;

    public boolean isTempFile = false;

    public boolean isFileNameDecode = false;

    public boolean conflictRename = false;

    public HttpRequestDownload() {
        method(HttpMethod.DOWNLOAD);
    }

    @Override
    public boolean isMD5Verify() {
        return isMD5Verify;
    }

    @Override
    public boolean isTempFile() {
        return isTempFile;
    }

    @Override
    public boolean isFileNameDecode() {
        return isFileNameDecode;
    }

    @Override
    public boolean isConflictRename() {
        return conflictRename;
    }

    @Override
    public String getFileDir() {
        return fileDir;
    }

    @Override
    public String getFileName() {
        return fileName;
    }

    @Override
    public HttpRequestDownload setFileDir(String fileDir) {
        this.fileDir = fileDir;
        return this;
    }

    @Override
    public HttpRequestDownload setFileName(String fileName) {
        this.fileName = fileName;
        return this;
    }

    @Override
    public HttpRequestDownload setMD5Verify(boolean MD5Verify) {
        isMD5Verify = MD5Verify;
        return this;
    }

    @Override
    public HttpRequestDownload setTempFile(boolean tempFile) {
        isTempFile = tempFile;
        return this;
    }

    @Override
    public HttpRequestDownload setFileNameDecode(boolean fileNameDecode) {
        isFileNameDecode = fileNameDecode;
        return this;
    }

    @Override
    public HttpRequestDownload setConflictRename(boolean conflictRename) {
        this.conflictRename = conflictRename;
        return this;
    }

    @Override
    public void clear() {
        super.clear();
        fileDir = null;
        fileName = null;
        isMD5Verify = false;
        isFileNameDecode = false;
        isTempFile = false;
    }

    @Override
    public HttpTag.DownloadListeners downloadProgressListeners() {
        HttpTag.DownloadListeners downloadListeners = super.downloadProgressListeners();
        downloadListeners.fileDir = getFileDir();
        downloadListeners.fileName = getFileName();
        downloadListeners.isFileNameDecode = isFileNameDecode();
        downloadListeners.isMD5Verify = isMD5Verify();
        downloadListeners.isTempFile = isTempFile();
        downloadListeners.conflictRename = isConflictRename();
        return super.downloadProgressListeners();
    }

    public String toParamJson() {
        return "{\"fileName\":\"" + getFileName() + "\"," +
                "\"fileDir\":\"" + getFileDir() + "\"," +
                "\"isMD5Verify\":\"" + isMD5Verify() + "\"," +
                "\"isMD5Verify\":\"" + isMD5Verify() + "\"," +
                "\"isTempFile\":\"" + isTempFile() + "\"," +
                "\"isFileNameDecode\":\"" + isFileNameDecode() + "\"," +
                "\"conflictRename\":\"" + isConflictRename() + "\"}";
    }
}
